package com.windo.helloBubble;

import java.util.ArrayList;

import com.windo.helloBubble.Views.HomeFeatureLayout;
import com.windo.helloBubble.objects.Bubble;
import com.windo.helloBubble.objects.Bubbles;
import com.windo.helloPad.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.GestureDetector;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.Display;
import android.view.MotionEvent;
import android.view.View;
import android.widget.FrameLayout.LayoutParams;

public class SwipeView extends Activity {
	private static final int SWIPE_MIN_DISTANCE = 120;
	private static final int SWIPE_MAX_OFF_PATH = 250;
	private static final int SWIPE_THRESHOLD_VELOCITY = 200;
	private GestureDetector gestureDetector;
	private HomeFeatureLayout mySwipe;
	DisplayMetrics displaymetrics = new DisplayMetrics();
	Bubbles bubblePool;
    
	@Override
	public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
      //  Log.v("DDMS", "Faked here0");
        mySwipe = new HomeFeatureLayout(this);
        		
       // ArrayList mItems = new ArrayList();
        //Log.v("DDMS", "Faked here");
       // mItems.add(new Bubble(0, 0, 0, 0, null));
        //mItems.add(new Bubble(0, 0, 0, 0, null));
        getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
        int ht = displaymetrics.heightPixels;
        int wt = displaymetrics.widthPixels;
        
        bubblePool = new Bubbles(this);
        
        mySwipe.setFeatureItems(wt);
       // Log.v("DDMS", "Faked here2");
        setContentView(R.layout.s_swipe);
        
        this.addContentView(mySwipe, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
        /*gestureDetector = new GestureDetector(new MyGestureDetector());
        View mainview = (View) findViewById(R.id.mainView);
        
        // Set the touch listener for the main view to be our custom gesture listener
        mainview.setOnTouchListener(new View.OnTouchListener() {
            public boolean onTouch(View v, MotionEvent event) {
                if (gestureDetector.onTouchEvent(event)) {
                    return true;
                }
                return false;
            }
        });*/
	}
	
	
	
	/*class MyGestureDetector extends SimpleOnGestureListener {
		@Override
        public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
	    Intent intent = new Intent(SwipeView.this.getBaseContext(), SwipeViewRight.class);
 
            if (Math.abs(e1.getY() - e2.getY()) > SWIPE_MAX_OFF_PATH) {
                return false;
            }
 
            // right to left swipe
            if(e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
	    		startActivity(intent);
	    		SwipeView.this.overridePendingTransition(
				R.anim.slide_in_right,
				R.anim.slide_out_left
    		);
    	    // right to left swipe
            }  else if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
	    		startActivity(intent);
	    		SwipeView.this.overridePendingTransition(
				R.anim.slide_in_left, 
				R.anim.slide_out_right
    		);
            }
 
            return false;
        }
 
        // It is necessary to return true from onDown for the onFling event to register
        @Override
        public boolean onDown(MotionEvent e) {
	        	return true;
        }
    }*/
}
